/*******************************************************************************
 * @file sht2x.h
 * @brief Sensirion - SHT2x sensor driver.
 *
 * @version 1.0.0
 *******************************************************************************
 * @license Refer License or other description Docs
 * @author  Felix
 ******************************************************************************/
#ifndef SENSOR_SHT2X_H
#define SENSOR_SHT2X_H

#include <stdint.h>
#include <stdbool.h>
#include <string.h>

/**
 *  I2C address: [7 bits addrss | 1 bit R/W ]
 *
 *  this addrss should be left shift 1 bit and append the last bit for R/W
 *  0x80 = (0x40 << 1)
 */
#define I2C_ADDR_SHT2X          0x80

typedef enum {
    SHT2X_MASTER_T    = 0xE3,  /* measurement teamperature */
    SHT2X_MASTER_RH   = 0xE5,  /* measurement humidity */
    SHT2X_POLL_T      = 0xF3,
    SHT2X_POLL_RH     = 0xF5,
    SHT2X_REG_W       = 0xE6,
    SHT2X_REG_R       = 0xE7,
    SHT2X_SOFT_RESET  = 0xFE
} SHT2xCommand;

typedef enum {
    SHT2X_RES_12_14BIT  = 0x00,
    SHT2X_RES_08_12BIT  = 0x01,
    SHT2X_RES_10_13BIT  = 0x80,
    SHT2X_RES_11_11BIT  = 0x81,
    SHT2X_RES_MASK      = 0x81
} SHT2xResolution;

typedef enum {
    SHT2X_EOB_ON        = 0x40,
    SHT2X_EOB_MASK      = 0x40
} SHT2xEob;

bool shtx_init(const uint8_t addr, void *sp);

#endif
